$(function(){
	$("#myForm").Validform({
		btnSubmit: "#tijiao",
		tiptype: 4,
		callback: function() {
			var userName=app.userName;
			var phone=app.phone;
			var address=app.address;
			var keyContactsphone=app.keyContactsphone;
			var sex=app.sex;
			var positionId=app.positionId;
			var identityCode=app.identityCode;
			var age=app.age;
			var frontName=app.frontName;
			var backName=app.backName;


			var data=new URLSearchParams();
			data.append("userName",userName);
			data.append("address",address);
			data.append("keyContactsphone",keyContactsphone);
			data.append("sex",sex);
			data.append("phone",phone);
			data.append("positionId",positionId);
			data.append("identityCode",identityCode);
			data.append("age",age);
			data.append("frontName",frontName);
			data.append("backName",backName);

			axios({
				method:"post",
				url:"yly-api/admin/addEmpAccount",
				data:data,
				headers:{"url":window.location.pathname,"token":localStorage.token}
			}).then(
				function(res) {
					console.log(res);
					if (res.data.code==200){
						console.log(res.data.data);
						if (res.data.data==true){
							alert("添加成功,初始密码为123456！");
							location.href="director-list.html";
						}else {
							alert("添加失败，该身份证已被使用！");
						}
					}else if (res.data.code==500){
						location.href="500.html";
					}
				}
			).catch(function (error) {
				console.log(error.response.status);
				if (error.response.status==401){
					alert("权限不足，请先登录!");
					location.href="login.html";
				}else if (error.response.status==403){
					alert("用户已过期，请重新登录！");
					localStorage.token=null;
					location.href="login.html";
				}
			});
			return false;
		}
	});
})